#include <iostream>
#include <string.h>
#include <math.h>
using namespace std;



struct item{
	int weight,value,number;
};



int main(){
	int t,m;
	cin>>m>>t;
	int dp[t];
	item a[m];
	memset(dp,0,sizeof(dp));
	for(int i=0;i<m;i++)
		cin>>a[i].value>>a[i].weight>>a[i].number;
	for(int i=1;i<=m;i++){
		for(int j=a[i-1].weight;j<=t;j++){
			int kMax = min(a[i-1].number, j/a[i-1].weight);
			for(int k=0; k<=kMax; k++){
//  				cout<<"i="<<i<<" j="<<j<<" kMax="<<kMax<<" j-"<<a[i-1].weight<<"*"<<k<<"="<<(j-a[i-1].weight*k)<<endl;
				dp[j] = max(dp[j],dp[j-a[i-1].weight*k]+a[i-1].value*k);
			}			
			cout<<"dp["<<j<<"]="<<dp[j]<<" ";
		}
		cout<<endl;
	}
//	for(int i=0.9999*t;i<=t;i++){
//		cout<<dp[i]<<" ";
//	}
//	cout<<endl;
	cout<<dp[t];
	return 0;
}
/* 
case 1
4 20
3 9 3
5 9 1
9 4 2
8 1 3

47
*/
